{extend name="ace/layout/default" /}

{block name="title"}角色管理{/block}

{block name="content"}
<h3 class="header smaller lighter blue">
    角色列表
    <small>
        <i class="icon-double-angle-right"></i>
        Roles list
    </small>
</h3>
<div class="row">
    <div class="col-xs-12 col-sm-12 col-ml-12">
        <a href="{:url('detail') }">
            <button class="btn btn-sm btn-success">
                <i class="icon-zoom-in bigger-120"></i>
                添加角色
            </button>
        </a>
        <a href="javascript:;" onclick="batchDelOperation('{:url(\'delete\')}');">
            <button type="button" class="btn btn-sm btn-danger">
                <i class="icon-trash bigger-120"></i>
                批量删除
            </button>
        </a>
        <a href="javascript:;" onclick="batchExport('{:url(\'export\')}');">
            <button class="btn btn-sm btn-info">
                <i class="icon icon-cloud-download bigger-120"></i>
                导出
            </button>
        </a>
    </div>
    <div class="col-xs-12 col-sm-12 col-ml-12">
        <div class="space-4"></div>
        <form action="" method="get" id="form_data" class="first_form float-left">
            <?php $is_check = input('is_check', -1); ?>
            <select name="is_check">
                <option value="-1" {if $is_check == -1}selected{/if}> 请选择状态 </option>
                <option value="1" {if $is_check == 1}selected{/if}> 正常 </option>
                <option value="0" {if $is_check == 0}selected{/if}> 禁用 </option>
            </select>
            <span class="input-icon">
                <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input"
                       autocomplete="off" name="search" value="{:input('search', '')}"/>

                <button type="button" class="btn btn-purple btn-sm" onclick="$('form.first_form').submit();">
                    Search
                    <i class="icon-search icon-on-right bigger-110"></i>
                </button>
            </span>
        </form>
    </div>
</div>
<div class="space-4"></div>
<div class="table-header">Roles list</div>
<div class="table-responsive">
    <table id="sample-table-1" class="table table-striped table-bordered table-hover">
        <thead>
        <tr>
            <th class="center">
                <label>
                    <input type="checkbox" class="ace" name="role_id[]" />
                    <span class="lbl"></span>
                </label>
            </th>
            <th class="text-center"> Id </th>
            <th class="text-center"> 角色名称 </th>
            <th class="text-center hidden-sm hidden-xs hidden-md"> 创建时间 </th>
            <th class="text-center"> 状态 </th>
            <th class="text-center"> 操作 </th>
        </tr>
        </thead>
        <tbody>
        {if !empty($list) && $list->total()}
        {foreach $list as $key => $item}
        <tr id="id_{$item->role_id}" name="{$item->role_name}">
            <td class="text-center">
                <label>
                    {if $item->role_id != 1}
                    <input type="checkbox" class="ace" name="role_id[]" value="{$item->role_id}" />
                    {/if}
                    <span class="lbl"></span>
                </label>
            </td>
            <td class="text-center"> <a href="javascript:;">{$item->role_id}</a> </td>
            <td class="text-center"> {$item->role_name} </td>
            <td class="text-center hidden-sm hidden-xs hidden-md">
                {:date('Y-m-d H:i', $item->created_time)}
            </td>
            <td class="text-center">
                {switch $item->is_check|intval }
                {case 1}
                <span class="label label-success"> 正常 </span>
                {/case}
                {default /}
                <span class="label label-danger"> 禁用 </span>
                {/switch}
            </td>
            <td class="text-center">
                <div class="hidden-sm hidden-xs action-buttons">
                    {if $item->role_id != 1}
                        {switch $item->is_check|intval }
                        {case 1}
                        <a class="btn btn-xs btn-danger" title="禁用“{$item->role_name}”角色" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'role_id' : '{$item->role_id}', 'change_field' : 'is_check', 'change_value':0})">
                            <i class="icon-lock bigger-120"></i> 禁用
                        </a>
                        {/case}
                        {default /}
                        <a class="btn btn-xs btn-success" title="启用“{$item->role_name}”角色" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'role_id' : '{$item->role_id}', 'change_field' : 'is_check', 'change_value':1})">
                            <i class="icon-unlock bigger-120"></i> 启用
                        </a>
                        {/switch}
                    {/if}


                    {if $item->role_id != 1}
                    <a class="btn btn-xs btn-info" title="编辑“{$item->role_name}”角色" href="{:url('detail', ['role_id' => $item->role_id])}">
                        <i class="icon-edit bigger-120"></i> 编辑
                    </a>
                    <a class="btn btn-xs btn-danger" title="删除“{$item->role_name}”<角色" onclick="delOperation({$item->role_id}, '{:url(\'delete\')}')">
                        <i class="icon-trash bigger-120"></i> 删除
                    </a>
                    {else /}
                    <a class="btn btn-xs btn-info" title="查看“{$item->role_name}”角色" href="{:url('detail', ['role_id' => $item->role_id])}">
                        <i class="icon-eye-open bigger-120"></i> 查看
                    </a>
                    {/if}
                </div>
                <div class="hidden-md hidden-lg">
                    <div class="inline position-relative">
                        <button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown" data-position="auto">
                            <i class="icon-cog bigger-110"></i>
                        </button>
                        <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                            {if $item->role_id != 1}
                                {switch $item->is_check|intval }
                                {case 1}
                                <li>
                                    <a class="btn btn-xs btn-danger" title="禁用“{$item->role_name}”角色" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'role_id' : '{$item->role_id}', 'change_field' : 'is_check', 'change_value':0})">
                                        <i class="icon-lock bigger-120"></i> 禁用
                                    </a>
                                    <div class="hr hr-dotted"></div>
                                </li>
                                {/case}
                                {default /}
                                <li>
                                    <a class="btn btn-xs btn-success" title="启用“{$item->role_name}”角色" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'role_id' : '{$item->role_id}', 'change_field' : 'is_check', 'change_value':1})">
                                        <i class="icon-unlock bigger-120"></i> 启用
                                    </a>
                                    <div class="hr hr-dotted"></div>
                                </li>
                                {/switch}
                            {/if}

                            {if $item->role_id != 1}
                            <li>
                                <a class="btn btn-xs btn-info" title="编辑“{$item->role_name}”角色" href="{:url('detail', ['role_id' => $item->role_id])}">
                                    <i class="icon-edit bigger-120"></i> 编辑
                                </a>
                            </li>
                            <li>
                                <div class="hr hr-dotted"></div>
                                <a class="btn btn-xs btn-danger" title="删除“{$item->role_name}”角色" onclick="delOperation({$item->role_id}, '{:url(\'delete\')}')">
                                    <i class="icon-trash bigger-120"></i> 删除
                                </a>
                            </li>
                            {else /}
                            <li>
                                <a class="btn btn-xs btn-info" title="查看“{$item->role_name}”角色" href="{:url('detail', ['role_id' => $item->role_id])}">
                                    <i class="icon-eye-open bigger-120"></i> 查看
                                </a>
                            </li>
                            {/if}
                        </ul>
                    </div>
                </div>
            </td>
        </tr>
        {/foreach}
        {/if}
        </tbody>
    </table>

    <div class="hr hr-18 dotted hr-double"></div>

    {if !empty($list) && $list->total()}
        <div id="pageList" class="float-right">
            {$list|raw}
        </div>
    {/if}
</div><!-- /.table-responsive -->
{/block}